<html>
<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<title>Nuvoton ESensor Test Page</title>
		<link rel="icon" type="image/x-ico" href="../img/nuvoton.ico" />
		<link rel="shortcut icon" type="image/x-icon" href="../img/nuvoton.ico" />
		<script type="text/javascript" src="../jquery/js/jquery.min.js"></script>
		
		<script type="text/javascript">
		//<![CDATA[
		
		$(document).ready(function(e)
		{
			$("#btnSetReg").click(function()
			{
				if($("#RegAddr").val() == "")
				{
					alert("Please specified register address!");
					$("#RegAddr").focus();
					return ;
				}
				
				if($("#WriteRegVal").val() == "")
				{
					alert("Please specified register value!");
					$("#WriteRegVal").focus();
					return ;
				}
				
				varRegAddr = parseInt($("#RegAddr").val(), 16);
				varWriteRegVal = parseInt($("#WriteRegVal").val(), 16);
				
				$.get("/server.command?command=set_sensor_reg&type=" + $("#selVideoType").val() + "&pipe=0&addr=" + varRegAddr + "&value=" + varWriteRegVal, function(data){
					$("#btnGetReg").trigger("click");
				});
			});
			
			$("#btnGetReg").click(function()
			{
				if($("#RegAddr").val() == "")
				{
					alert("Please specified register address!");
					$("#RegAddr").focus();
					return ;
				}
				
				varRegAddr = parseInt($("#RegAddr").val(), 16);
				
				$.get("/server.command?command=get_sensor_reg&type=" + $("#selVideoType").val() + "&pipe=0&addr=" + varRegAddr, function(data){
					varReadRegVal = data.value;
					$("#ReadRegVal").text((+varReadRegVal).toString(16).toUpperCase());
				});
			});
			
			$("#btnClearAll").click(function()
			{
				$("#RegAddr").val("");
				$("#WriteRegVal").val("");
				$("#ReadRegVal").text("");
			});
		});
		//]]>
		</script>
</head>
<body>
<table border="1" cellspacing="0">
<tr align="center">
	<td colspan="2">Test Sensor Register</td>
</tr>
<tr>
	<td>Video Type</td>
	<td>
		<select id="selVideoType">
		<option value="jpeg">JPEG</option>
		<option value="h264">H.264</option>
		</select>
	</td>
</tr>
<tr>
	<td>Address</td>
	<td>0x<input id="RegAddr" type="text" maxlength="4" size="8" onkeyup="value=value.replace(/[^A-Fa-f0-9]/g,'')"></td>
</tr>
<tr>
	<td>Write Value</td>
	<td>0x<input id="WriteRegVal" type="text" maxlength="4" size="8" onkeyup="value=value.replace(/[^A-Fa-f0-9]/g,'')"></td>
</tr>
<tr>
	<td>Read Value</td>
	<td>0x<span id="ReadRegVal"></span></td>
</tr>
<tr align="right">
	<td colspan="2">
		<input id="btnSetReg" type="button" value="Set">
		<input id="btnGetReg" type="button" value="Get">
		<input id="btnClearAll" type="button" value="Clear">
	</td>
</tr>
<tr>
	<td colspan="2"><img src="/video.cgi"></td>
</tr>
</table>
</body>
</html>
